package com.zzy.edu.controller;


import com.zzy.commonutils.R;
import com.zzy.edu.entity.vo.excel.SubjectData;
import com.zzy.edu.entity.vo.subject.OneSubject;
import com.zzy.edu.service.EduSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author KAZU
 * @since 2023-01-11
 */
@SuppressWarnings("all")
@RestController
@RequestMapping("/eduservice/subject")
@CrossOrigin
public class EduSubjectController {
	
	@Autowired
	private EduSubjectService subjectService;
	
	/**
	 * 添加课程分类
	 * 获取上传过来的文件，吧文件内容读取出来
	 * */
	@PostMapping("addSubject")
	public R addSubject(MultipartFile file) throws IOException {
		subjectService.saveSubject(file, subjectService);
		return R.ok();
	}
	
	/**
	 * 课程分类列表（树形）
	 * */
	@GetMapping("getAllSubject")
	public R getAllSubject() {
		List<OneSubject> list = subjectService.getAllOneTwoSubject();
		return R.ok().data("list", list);
	}
	
}
